package com.polaris.live.widget.country

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.RelativeLayout
import com.polaris.live.databinding.WidgetCountryBigRoundBinding

/**
 * 圆形国家图片
 *
 * @author Created by 半仙 on 2023/10/26/026 20:30
 */
class CountryBigRoundView(context: Context, attributeSet: AttributeSet) :
    RelativeLayout(context, attributeSet) {

    private val mBinding =
        WidgetCountryBigRoundBinding.inflate(LayoutInflater.from(context), this, true)

    /**
     * 设置国家
     */
    fun setCountry(countryCode: String?) {
        if (countryCode != null) {
            val countryIcon = countryIcons[countryCode]
            if (countryIcon == null) {
                visibility = GONE
            } else {
                visibility = VISIBLE
                mBinding.ivIcon.setImageResource(countryIcon)
            }
        } else {
            visibility = GONE
        }
    }

}